// import hljs from 'highlight.js'
// import 'highlight.js/styles/googlecode.css'
// import 'highlight.js/styles/monokai-sublime.css'

import {createApp} from 'vue'
import App from './App.vue'
import {createRouter, createWebHashHistory} from 'vue-router'

import ElementUI from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import routes from './routes'
import Vant from 'vant'
import {createPinia} from 'pinia'

// 预览组件以及样式
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';
// VuePress主题以及样式（这里也可以选择github主题）
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
// emoji
import createEmojiPlugin from '@kangc/v-md-editor/lib/plugins/emoji/index';
import '@kangc/v-md-editor/lib/plugins/emoji/emoji.css';
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';
// 快速复制代码
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
import createTipPlugin from '@kangc/v-md-editor/lib/plugins/tip/index';
import '@kangc/v-md-editor/lib/plugins/tip/tip.css';

import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';

//
import VMdEditor from '@kangc/v-md-editor/lib/codemirror-editor';
import '@kangc/v-md-editor/lib/style/codemirror-editor.css';

// highlightjs

// codemirror 编辑器的相关资源
import Codemirror from 'codemirror';
// mode
import 'codemirror/mode/markdown/markdown';
import 'codemirror/mode/javascript/javascript';
import 'codemirror/mode/css/css';
import 'codemirror/mode/htmlmixed/htmlmixed';
import 'codemirror/mode/vue/vue';
// edit
import 'codemirror/addon/edit/closebrackets';
import 'codemirror/addon/edit/closetag';
import 'codemirror/addon/edit/matchbrackets';
// placeholder
import 'codemirror/addon/display/placeholder';
// active-line
import 'codemirror/addon/selection/active-line';
// scrollbar
import 'codemirror/addon/scroll/simplescrollbars';
import 'codemirror/addon/scroll/simplescrollbars.css';
// style
import 'codemirror/lib/codemirror.css';


// Prism
import Prism from 'prismjs';
// 代码高亮
// import 'prismjs/components/prism-json';

VMdEditor.Codemirror = Codemirror;
VMdEditor.use(vuepressTheme, {
	Prism,
	extend(md) {
		// md为 markdown-it 实例，可以在此处进行修改配置,并使用 plugin 进行语法扩展
		//md.use(require('markdown-it'))
	},
});

// 选择使用主题
VMdPreview.use(vuepressTheme, {
	Prism,
	extend(md) {
		// md为 markdown-it 实例，可以在此处进行修改配置,并使用 plugin 进行语法扩展
		//md.use(require('markdown-it'))
	},
});
VMdPreview.use(createLineNumbertPlugin());
VMdPreview.use(createCopyCodePlugin());
VMdPreview.use(createEmojiPlugin());
VMdPreview.use(createTipPlugin());
VMdPreview.use(createTodoListPlugin());


const router = createRouter({
	history: createWebHashHistory(),
	routes,
});
const app = createApp(App);
app.config.productionTip = false;
app.use(ElementUI, {
	locale: zhCn,
});
app.use(Vant);
app.use(router);
app.use(createPinia());
app.use(VMdPreview);
app.use(VMdEditor);
app.mount('#app');

// app.directive('highlight', function (el) {
// 	let blocks = el.querySelectorAll('pre code');
// 	blocks.forEach((block) => {
// 		hljs.highlightBlock(block);
// 	});
// });
